# -*- coding: utf-8 -*-
# Options
# ~~~~~~~

from docutils import nodes
from docutils.parsers.rst import directives, Directive

class Youtube(Directive):

    required_arguments = 1
    optional_arguments = 0

    def run(self):
        i = self.arguments[0]
        parsed = '<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/' + i + '&rel=0&color1=0xb1b1b1&color2=0xcfcfcf&feature=player_embedded&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/' + i + '&rel=0&color1=0xb1b1b1&color2=0xcfcfcf&feature=player_embedded&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="425" height="344"></embed></object>';
        return [nodes.raw('', parsed, format='html')]

directives.register_directive('youtube', Youtube)
